package com.umeox.watch.moto.launcher.ui.widget;

import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.widget.TextView;

import com.umeox.watch.moto.launcher.R;


public class AnalogClockDateView extends AnalogClockSimpleView {

    private TextView mDayTv;
    private TextView mWeekTv;
    private String mLastFormat;

    public AnalogClockDateView(Context context) {
        super(context);
    }

    public AnalogClockDateView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public AnalogClockDateView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }


    @Override
    protected void initView() {
        super.initView();
        mWeekTv = mView.findViewById(R.id.tv_week);
        mDayTv = mView.findViewById(R.id.tv_day);
    }

    @Override
    public void onTimeChange(long time) {
        final String format = mDateFormat.format(time);
        if (TextUtils.equals(format,mLastFormat)){
            return;
        }
        if (mWeekTv==null){
            return;
        }
        mLastFormat = format;
        final String[] date = mLastFormat.split("-");

        mWeekTv.setText(date[0]);
        mDayTv.setText(date[1]);
    }
}
